package com.rimi.lzhg.controller;

import com.rimi.lzhg.entry.Feedback;
import com.rimi.lzhg.response.ResponseEntity;
import com.rimi.lzhg.service.FeedbackService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class FeedbackController {

    @Autowired
    private FeedbackService feedbackService;

    @ApiOperation(value = "添加意见反馈",notes = "添加意见反馈")
    @PostMapping("/feedback")
    public Object saveFeedback(Feedback feedback){
        boolean b = feedbackService.saveFeedbackService(feedback);
        if(b){
            return ResponseEntity.success("意见提交成功");
        }
        return ResponseEntity.error("意见保存失败?请检查信息重试");
    }

    @ApiOperation(value = "查询意见反馈列表",notes = "查询意见反馈列表")
    @GetMapping("/feedback")
    public Object getFeedBackList(){
        List<Feedback> feedbackList = feedbackService.getFeedbackList();
        return ResponseEntity.success(feedbackList.size(),feedbackList);
    }

}
